package com.daiyang.seckill.vo;

import lombok.AllArgsConstructor;
import lombok.Data;

@AllArgsConstructor
@Data
public class RespBean {
    private long code;
    private String message;
    private Object data;

    //成功后
    public static  RespBean success(Object data){
        return
                new RespBean
                (RespBeanEnum.SUCCESS.getCode(),
                        RespBeanEnum.SUCCESS.getMessage(),
                        data);
    }
    public static   RespBean  success(){
        return new RespBean
                        (RespBeanEnum.SUCCESS.getCode(),
                                RespBeanEnum.SUCCESS.getMessage(),
                                null);
    }
    public static  RespBean  error(RespBeanEnum respBeanEnum){
        return new RespBean
                        (respBeanEnum.getCode(),
                                respBeanEnum.getMessage(),
                                null);
    }
    public static  RespBean error(RespBeanEnum respBeanEnum, Object data){
        return new RespBean
                        (respBeanEnum.getCode(),
                                respBeanEnum.getMessage(),
                                data);
    }


}
